package com.yunxi.service.dubboService.impl.sto;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.util.BeanTools;
import com.yunxi.model.sto.StoStockOut;
import com.yunxi.service.localService.sto.StoStockOutService;
import com.yunxi.sto.pojo.StoStockOutVO;
import com.yunxi.sto.service.StoStockOutDubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import java.lang.reflect.InvocationTargetException;

/**
 * <p>
 * 车辆出库单 服务实现类
 * </p>
 *
 * @author caoYong
 * @since 2019-05-21
 */
public class StoStockOutDubboServiceImpl implements StoStockOutDubboService {

    @Autowired
    @Qualifier(value = "stoStockOutServiceImpl")
    StoStockOutService stoStockOutService;


    @Override
    public StoStockOutVO getById(String id) throws Exception{
        StoStockOut stoStockOut = stoStockOutService.getById(id);
        if(stoStockOut == null){
            throw new Exception("操作失败,无法根据主键ID "+id+" 找到对应记录!");
        }
        StoStockOutVO stoStockOutVO = new StoStockOutVO();
        BeanTools.copyProperties(stoStockOutVO,stoStockOut);
        return stoStockOutVO;
    }

    @Override
    public void saveOrUpdate(StoStockOutVO stoStockOutVO) {
        StoStockOut stoStockOut = new StoStockOut();
        BeanTools.copyProperties(stoStockOut,stoStockOutVO);
        stoStockOutService.saveOrUpdate(stoStockOut);
    }

    @Override
    public void removeById(String id) {
    stoStockOutService.removeById(id);
    }

    @Override
    public PageInfo<StoStockOutVO> findPageByVO(StoStockOutVO stoStockOutVO, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {
        PageInfo<StoStockOutVO> pageInfo = stoStockOutService.pageByVo(stoStockOutVO, pageNum, pageSize);
        return pageInfo;
    }

}
